package com.ynhenc.pta.routeRank.impl;

import com.ynhenc.pta.routeRank.*;

public class TestData {

	public void makeRouteResultListData(RouteResultList routeResultList) {

		if (routeResultList == null) {
			// do nothing !!!!
		} else {
			for (int i = 0, iLen = 3; i < iLen; i++) {
				SectionList sectionList = new SectionList();
				RouteSearchType routeSearchType = RouteSearchType.GREEN_01;
				if (i % 3 == 0) {
					routeSearchType = RouteSearchType.SHORTEST;
				} else if (i % 3 == 1) {
					routeSearchType = RouteSearchType.GREEN_02;
				} else if (i % 3 == 2) {
					routeSearchType = RouteSearchType.GREEN_01;
				}
				int no = ROUTE_RANK_IMPL_NO;
				this.makeSectionListData(sectionList, routeSearchType, no);
				RouteResultImpl routeResult = new RouteResultImpl(sectionList, routeSearchType);
				routeResultList.add(routeResult);
			}

			ROUTE_RANK_IMPL_NO++;
		}
	}

	public void makeSectionListData(SectionList sectionList, RouteSearchType routeSearchType, int no) {
		int pathNo = 0;
		/*
		if (false) {
			TransitType transitType = TransitType.AUTOMOBILE;
			PathImpl path = new PathImpl();
			this.makePathData(path, pathNo);
			String nameSection = "0. 자택->유치원";
			SectionImpl section = new SectionImpl(nameSection, transitType, path);
			sectionList.add(section);
			pathNo++;
		}
		if (true) {
			TransitType transitType = TransitType.WALK;
			PathImpl path = new PathImpl();
			this.makePathData(path, pathNo);
			String nameSection = "2. 유치원 -> 환승주차장";
			SectionImpl section = new SectionImpl(nameSection, transitType, path);
			sectionList.add(section);
			pathNo++;
		}
		if (true) {
			TransitType transitType = TransitType.BUS;
			PathImpl path = new PathImpl();
			this.makePathData(path, pathNo);
			String nameSection = "3. 시청 -> 환승주차장";
			SectionImpl section = new SectionImpl(nameSection, transitType, path);
			sectionList.add(section);
			pathNo++;
		}
		if (true) {
			TransitType transitType = TransitType.SUBWAY;
			PathImpl path = new PathImpl();
			this.makePathData(path, pathNo);
			String nameSection = "4. 시청 -> 환승주차장";
			SectionImpl section = new SectionImpl(nameSection, transitType, path);
			sectionList.add(section);
			pathNo++;
		}
		*/
	}

	private void makePathData(PathImpl path, int no) {
		int dataNo = no % (pathData.length);
		if (path != null) {
			this.addVertexList(path, pathData[dataNo]);
		}
	}

	public void addVertexList(PathImpl path, double[] poly) {
		if (poly == null) {
			// do nothing !!!!
		} else {
			final double convFactor = 256 * 2048;
			int no = poly.length / 2;
			double x, y;
			for (int i = 0, iLen = no; i < iLen; i++) {
				x = poly[2 * i];
				y = poly[2 * i + 1];

				System.out.println("test index(" + i + ")" + " test : " + x + ", " + y);

				if (i == 0) {
					path.addVertex(new Node(x, y, ""));
				} else if (i < no - 1) {
					path.addVertex(x, y);
				} else {
					path.addVertex(new Node(x, y, ""));
				}
			}
		}
	}

	public static int ROUTE_RANK_IMPL_NO = 0;

	double[][] pathData = {
	// 0. 자택->유치원
			new double[] { 126.9263996856966, 37.55092838785571, 126.9451109085887, 37.54918169320838, 126.9585059435391, 37.54497332583365, 126.9642594746513, 37.55322366374977, },

			// 2. 유치원 -> 환승주차장
			new double[] { 126.9586101813565, 37.56577124040948, 126.9752158934055, 37.5692835827205, },

			// 3. 유치원 -> 환승주차장
			new double[] { 126.9762122938669, 37.56928364750433, 127.0037780395779, 37.56024357496727, 127.0089773791217, 37.54532342000451, 126.9934801697452, 37.536725641117, 126.9789814091637,
					37.54787212640593, },

			// 4.시청 -> 환승주차장
			new double[] { 126.9793126984234, 37.56024539279733, 126.9735562273745, 37.56173683109196, }, 
			};

}
